<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <table>
        <h1>添加博客或修改</h1>
        <tr>
            <td>标题</td>
            <td><input type="text" id="headline "></td>
        </tr>
        <tr>
            <td>摘要</td>
            <td><input type="text" id="abstract"></td>
        </tr>
        <tr>
            <td>内容</td>
            <td><input type="text" id="content "></td>
        </tr>
        <tr>
            <td>分类</td>
            <td><input type="text" id="classify  "></td>
        </tr>
        <tr>
            <td>作者</td>
            <td><input type="text" id="author"></td>
        </tr>
        <tr>
            <td><input type="button" value="保存" onclick="save()"></td>
            <td><input type="button" value="返回" onclick="cancel()"></td>
        </tr>
    </table>
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./js/api.js"></script>

    <script>  $(function(){
        let url = window.location.search
        if(url){
            let id =url.split('?')[1].split('=')[1]
            getListById(id).then(res=>{
                $('[name=headline]').val(res.data.headline)
                $('[name=abstract]').val(res.data.abstract)
                $('[name=content]').val(res.data.content)
                $('[name=classify]').val(res.data.classify)
                $('[name=author]').val(res.data.author)
            })
        }
    })
    </script>
</body>
</html>